package com.sangu.dianxiu.ui;

import android.annotation.TargetApi;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSONObject;
import com.android.volley.VolleyError;
import com.facebook.drawee.view.SimpleDraweeView;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sangu.dianxiu.BaseApp;
import com.sangu.dianxiu.ICallBack;
import com.sangu.dianxiu.ISuccessCallback;
import com.sangu.dianxiu.R;
import com.sangu.dianxiu.bean.basedata.PhrasesCommentEntity;
import com.sangu.dianxiu.bean.order.CancelOrderEntity;
import com.sangu.dianxiu.bean.order.OrderDetailEntity;
import com.sangu.dianxiu.task.DownloadVoiceAsyncTask;
import com.sangu.dianxiu.utils.BaseDataManager;
import com.sangu.dianxiu.utils.ImageLoaderHelper;
import com.sangu.dianxiu.utils.RepairOrderManager;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;

public class OrderDetailActivity extends BaseActivity {
    private DisplayImageOptions displayImage= ImageLoaderHelper.getDisplayImageLoader();        //使用universalimageloader图片加载
    private ISuccessCallback iSuccessCallback;

    private RepairOrderManager orderManager=new RepairOrderManager();                               //使用此类进行维修订单数据请求
    private BaseDataManager baseDataManager=new BaseDataManager();                                  //使用此类进行基础数据网络请求
    private long orderId;                                                                           //订单id
    private OrderDetailEntity detailEntity;                                                         //订单详情实体
    private String voicePath;                                                                         //语音文件的路径
    private int reccordTime;                                                                           //语音文件的时间
    private MediaPlayer mediaPlayer=new MediaPlayer();                                          //媒体播放器
    private boolean isPlaying=false;                                                            //是否正在播放
    private boolean isAccepted=false;                                                            //是否已接单
    private Bitmap bitmap1;                                                                     //图片1
    private Bitmap bitmap2;                                                                         //图片2
    private Bitmap bitmap3;                                                                         //图片3
    private Dialog commentDialog;                                                                   //评论界面
    @ViewInject(R.id.tv_activity_order_detail_project)                                              //使用xutils的注解功能，这样就不用findviewbyid了
    private TextView tvProjectName;
    @ViewInject(R.id.tv_activity_order_detail_status)
    private TextView tvStatus;
    @ViewInject(R.id.tv_activity_order_detail_ordertime)
    private TextView tvOrderTime;
    @ViewInject(R.id.tv_activity_order_detail_orderNo)
    private TextView tvOrderNo;
    @ViewInject(R.id.tv_activity_order_detail_address)
    private TextView tvAddress;
    @ViewInject(R.id.tv_activity_order_detail_repairtime)
    private TextView tvRepairTime;
    @ViewInject(R.id.iv_activity_order_detail_img1)
    private ImageView ivImg1;
    @ViewInject(R.id.iv_activity_order_detail_img2)
    private ImageView ivImg2;
    @ViewInject(R.id.iv_activity_order_detail_img3)
    private ImageView ivImg3;
    @ViewInject(R.id.rl_activity_order_detail_voice)
    private RelativeLayout rlVoice;
    @ViewInject(R.id.iv_activity_order_detail_voice)
    private ImageView ivVoice;
    @ViewInject(R.id.tv_activity_order_detail_time)
    private TextView tvTimeLong;
    @ViewInject(R.id.tv_activity_order_detail_reason)
    private TextView tvReason;
    @ViewInject(R.id.btn_activity_order_detail_modify)
    private Button btnModify;
    @ViewInject(R.id.btn_activity_order_detail_cancel)
    private Button btnCancel;
    @ViewInject(R.id.btn_activity_order_detail_hascanceled)
    private Button btnHasCancel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);
        ViewUtils.inject(this);                                                         //如果没有此行代码，则注解不会生效
        init();
        loadData();
    }

    private void init() {
        orderId=getIntent().getIntExtra("orderId", 0);                                   //从上一个界面获得订单id
    }

    //加载数据
    private void loadData() {
        HashMap<String,String> map=new HashMap<>();
        map.put("userId", BaseApp.user.getUserId()+"");
        map.put("orderId", orderId + "");
        orderManager.getOrderDetail(map, new ICallBack() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void onSuccess(String string) {
                detailEntity= JSONObject.parseObject(string,OrderDetailEntity.class);
                if(detailEntity.getRc()==0)
                {
                    tvProjectName.setText(detailEntity.getOrder().getItems().get(0).getItemName());
                    switch (detailEntity.getOrder().getStatus())
                    {
                        case 0:
                            tvStatus.setText("已取消");
                            btnModify.setVisibility(View.GONE);
                            btnCancel.setVisibility(View.GONE);
                            btnHasCancel.setVisibility(View.VISIBLE);
                            btnHasCancel.setEnabled(false);
                            break;
                        case 1:
                            tvStatus.setText("报修中");
                            break;
                        case 2:
                            tvStatus.setText("已接单");
                            isAccepted=true;
                            break;
                        case 3:
                            tvStatus.setText("待付款");

                            break;
                        case 4:
                            tvStatus.setText("已付款");

                            break;
                        case 5:
                            tvStatus.setText("已结算");
                            if (!detailEntity.getOrder().isIsComment())                  //如果还没有评价则显示评价界面
                            {
                                showCommentDialog();
                            }
                            break;
                    }

                    tvOrderTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(detailEntity.getOrder().getAddTime()));
                    tvOrderNo.setText(detailEntity.getOrder().getOrderNo());
                    tvRepairTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(detailEntity.getOrder().getOrderTime()));
                    tvAddress.setText(detailEntity.getOrder().getAddr().getAddr());
                    tvReason.setText(detailEntity.getOrder().getDesc().getText());
                    if(!TextUtils.isEmpty(detailEntity.getOrder().getDesc().getImgUrl1()))
                    {
                        ivImg1.setVisibility(View.VISIBLE);
                        ImageLoader.getInstance().displayImage(detailEntity.getOrder().getDesc().getImgUrl1(),ivImg1,displayImage);
                    }else{
                        ivImg1.setVisibility(View.GONE);
                    }
                    if(!TextUtils.isEmpty(detailEntity.getOrder().getDesc().getImgUrl2()))
                    {
                        ivImg2.setVisibility(View.VISIBLE);
                        ImageLoader.getInstance().displayImage(detailEntity.getOrder().getDesc().getImgUrl2(), ivImg2, displayImage);
                    }else{
                        ivImg2.setVisibility(View.GONE);
                    }
                    if(!TextUtils.isEmpty(detailEntity.getOrder().getDesc().getImgUrl3()))
                    {
                        ivImg3.setVisibility(View.VISIBLE);
                        ImageLoader.getInstance().displayImage(detailEntity.getOrder().getDesc().getImgUrl3(), ivImg3, displayImage);
                    }else{
                        ivImg3.setVisibility(View.GONE);
                    }
                    if(!TextUtils.isEmpty(detailEntity.getOrder().getDesc().getVoiceUrl()))
                    {
                        new DownloadVoiceAsyncTask(new ISuccessCallback() {
                            @Override
                            public void success(String s) {
                                rlVoice.setVisibility(View.VISIBLE);
                                try {
                                    voicePath=s;
                                    mediaPlayer.setDataSource(s);
                                    mediaPlayer.prepare();
                                    reccordTime=mediaPlayer.getDuration()/1000;
                                    tvTimeLong.setText((int)(mediaPlayer.getDuration()/1000)+"”");
                                } catch (IOException e) {
                                    e.printStackTrace();
                                }

                            }
                        }).execute(detailEntity.getOrder().getDesc().getVoiceUrl());
                    }else{
                        ivVoice.setVisibility(View.GONE);
                    }
                }else{
                    Toast.makeText(OrderDetailActivity.this,"获取订单详情失败",Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onError(VolleyError error) {

            }
        });
    }
    //使用xutils的事件注解，这样就不用setonclicklistener了
    @OnClick({R.id.iv_activity_order_detail_back,R.id.tv_activity_order_detail_call,R.id.iv_activity_order_detail_img1,R.id.iv_activity_order_detail_img2,R.id.iv_activity_order_detail_img3
            ,R.id.iv_activity_order_detail_voice,R.id.btn_activity_order_detail_modify,R.id.btn_activity_order_detail_cancel})
    public void onClick(View view)
    {
        Intent intent;
        switch (view.getId())
        {
            case R.id.iv_activity_order_detail_back:
                finish();
                break;
            case R.id.tv_activity_order_detail_call:
                intent=new Intent();
                intent.setAction(Intent.ACTION_DIAL);
                String tel="tel:"+"400-888-888";
                Uri uri=Uri.parse(tel);
                intent.setData(uri);
                startActivity(intent);
                break;
            case R.id.iv_activity_order_detail_img1:

                break;
            case R.id.iv_activity_order_detail_img2:
                break;
            case R.id.iv_activity_order_detail_img3:
                break;
            case R.id.iv_activity_order_detail_voice:
                mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                    @Override
                    public void onCompletion(MediaPlayer mp) {
                        Toast.makeText(OrderDetailActivity.this, "播放完成",Toast.LENGTH_SHORT).show();
                    }
                });
                if(isPlaying)
                {
                    mediaPlayer.stop();
                    isPlaying=false;
                }else{
                    mediaPlayer.start();
                    isPlaying=true;
                }

                break;
            case R.id.btn_activity_order_detail_modify:
                intent=new Intent(this,OrderActivity.class);
                intent.putExtra("projectName",tvProjectName.getText().toString());
                intent.putExtra("projectId",orderId);
                intent.putExtra("addr",tvAddress.getText().toString());
                intent.putExtra("reason",tvReason.getText().toString());
                intent.putExtra("repairTime",tvRepairTime.getText().toString());
                intent.putExtra("orderNo",tvOrderNo.getText().toString());
                if(ivImg1.isShown())
                {
                    bitmap1=((BitmapDrawable)ivImg1.getDrawable()).getBitmap();
                }
                if(ivImg2.isShown())
                {
                    bitmap2=((BitmapDrawable)ivImg2.getDrawable()).getBitmap();
                }
                if(ivImg3.isShown())
                {
                    bitmap3=((BitmapDrawable)ivImg3.getDrawable()).getBitmap();
                }
                intent.putExtra("bitmap1",bitmap1);
                intent.putExtra("bitmap2",bitmap2);
                intent.putExtra("bitmap3",bitmap3);
                intent.putExtra("voicePath",voicePath);
                intent.putExtra("reccordTime",reccordTime+"");
                BaseApp.isModifying=true;
                startActivity(intent);
                break;

            case R.id.btn_activity_order_detail_cancel:
                if(isAccepted)
                {
                    Intent intent1=new Intent(this,CancelOrderActivity.class);
                    intent1.putExtra("orderId",orderId);
                    startActivity(intent1);
                }else{

                    HashMap<String,String> map=new HashMap<>();
                    map.put("userId",BaseApp.user.getUserId()+"");
                    map.put("orderId",orderId+"");
                    orderManager.cancelBeforeAccept(map, new ICallBack() {
                        @Override
                        public void onSuccess(String string) {
                            String s = string;
                            CancelOrderEntity entity = JSONObject.parseObject(string, CancelOrderEntity.class);
                            if (entity.getRc() == 0) {
                                Toast.makeText(OrderDetailActivity.this, "取消订单成功", Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(OrderDetailActivity.this, "取消订单失败", Toast.LENGTH_SHORT).show();
                            }
                        }

                        @Override
                        public void onError(VolleyError error) {

                        }
                    });
                }

                break;
        }
    }

    //显示评价界面
    ImageView ivRepairerStar1;
    ImageView ivRepairerStar2;
    ImageView ivRepairerStar3;
    ImageView ivRepairerStar4;
    ImageView ivRepairerStar5;
    TextView tvRepairerName;
    TextView tvRepairerSkill;
    TextView tvRepairerPhone;
    ImageView ivCommentLevel1;
    ImageView ivCommentLevel2;
    ImageView ivCommentLevel3;
    ImageView ivCommentLevel4;
    ImageView ivCommentLevel5;
    ImageView ivSelectPhrase1;
    ImageView ivSelectPhrase2;
    ImageView ivSelectPhrase3;
    ImageView ivSelectPhrase4;
    TextView tvPhrase1;
    TextView tvPhrase2;
    TextView tvPhrase3;
    TextView tvPhrase4;
    EditText etSuggession;
    Button btnSubmit;
    boolean isPhrase1Selected=false;
    boolean isPhrase2Selected=false;
    boolean isPhrase3Selected=false;
    boolean isPhrase4Selected=false;
    int checked1Count;
    int checked2Count;
    int checked3Count;
    int checked4Count;
    int commentLevel;
    private void showCommentDialog() {
        class MyListener implements View.OnClickListener{
            @Override
            public void onClick(View v) {
                switch (v.getId())
                {
                    case R.id.iv_comment_layout_big_rating1:
                        commentLevel=1;
                        ivCommentLevel1.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel2.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel3.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel4.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel5.setImageResource(R.mipmap.order_star_big_unselect2x);
                        break;
                    case R.id.iv_comment_layout_big_rating2:
                        commentLevel=2;
                        ivCommentLevel1.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel2.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel3.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel4.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel5.setImageResource(R.mipmap.order_star_big_unselect2x);
                        break;
                    case R.id.iv_comment_layout_big_rating3:
                        commentLevel=3;
                        ivCommentLevel1.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel2.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel3.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel4.setImageResource(R.mipmap.order_star_big_unselect2x);
                        ivCommentLevel5.setImageResource(R.mipmap.order_star_big_unselect2x);
                        break;
                    case R.id.iv_comment_layout_big_rating4:
                        commentLevel=4;
                        ivCommentLevel1.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel2.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel3.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel4.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel5.setImageResource(R.mipmap.order_star_big_unselect2x);
                        break;
                    case R.id.iv_comment_layout_big_rating5:
                        ivCommentLevel1.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel2.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel3.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel4.setImageResource(R.mipmap.order_star_big_selected2x);
                        ivCommentLevel5.setImageResource(R.mipmap.order_star_big_selected2x);
                        commentLevel=5;
                        break;
                    case R.id.iv_comment_layout_phrase1:
                        checked1Count++;
                        if(checked1Count%2==1)
                        {
                            ivSelectPhrase1.setImageResource(R.mipmap.order_checked2x);
                            isPhrase1Selected=true;
                        }else{
                            ivSelectPhrase1.setImageResource(R.mipmap.order_uncheck2x);
                            isPhrase1Selected=false;
                        }
                        break;
                    case R.id.iv_comment_layout_phrase2:
                        checked2Count++;
                        if(checked2Count%2==1)
                        {
                            ivSelectPhrase2.setImageResource(R.mipmap.order_checked2x);
                            isPhrase2Selected=true;
                        }else{
                            ivSelectPhrase2.setImageResource(R.mipmap.order_uncheck2x);
                            isPhrase2Selected=false;
                        }
                        break;
                    case R.id.iv_comment_layout_phrase3:
                        checked3Count++;
                        if(checked3Count%2==1)
                        {
                            ivSelectPhrase3.setImageResource(R.mipmap.order_checked2x);
                            isPhrase3Selected=true;
                        }else{
                            ivSelectPhrase3.setImageResource(R.mipmap.order_uncheck2x);
                            isPhrase3Selected=false;
                        }
                        break;
                    case R.id.iv_comment_layout_phrase4:
                        checked4Count++;
                        if(checked4Count%2==1)
                        {
                            ivSelectPhrase4.setImageResource(R.mipmap.order_checked2x);
                            isPhrase4Selected=true;
                        }else{
                            ivSelectPhrase4.setImageResource(R.mipmap.order_uncheck2x);
                            isPhrase4Selected=false;
                        }
                        break;
                    case R.id.btn_comment_layout_submit:
                        HashMap<String,String> map=new HashMap<>();
                        map.put("userId",BaseApp.user.getUserId()+"");
                        map.put("orderId",orderId+"");
                        map.put("star",commentLevel+"");
                        map.put("phrases", null);
                        map.put("comment",etSuggession.getText().toString());
                        orderManager.comment(map, new ICallBack() {
                            @Override
                            public void onSuccess(String string) {
                                String s=string;
                            }

                            @Override
                            public void onError(VolleyError error) {

                            }
                        });
                        break;
                }
            }
        }
        ArrayList<ImageView> ivRepairerStars=new ArrayList<>();         //将星星对象都添加到arraylist里面，便于用for循环来改变相应的图片
        ArrayList<ImageView> ivCommentStars=new ArrayList<>();          //将星星对象都添加到arraylist里面，便于用for循环来改变相应的图片
        MyListener listener=new MyListener();
        View view = getLayoutInflater().inflate(R.layout.comment_layout, null);         //加载评价视图
        ivRepairerStar1= (ImageView) view.findViewById(R.id.iv_comment_layout_small_rating1);
        ivRepairerStar2= (ImageView) view.findViewById(R.id.iv_comment_layout_small_rating2);
        ivRepairerStar3= (ImageView) view.findViewById(R.id.iv_comment_layout_small_rating3);
        ivRepairerStar4= (ImageView) view.findViewById(R.id.iv_comment_layout_small_rating4);
        ivRepairerStar5= (ImageView) view.findViewById(R.id.iv_comment_layout_small_rating5);
        tvRepairerName= (TextView) view.findViewById(R.id.tv_comment_layout_name);
        tvRepairerSkill= (TextView) view.findViewById(R.id.tv_comment_layout_skill);
        tvRepairerPhone= (TextView) view.findViewById(R.id.tv_comment_layout_phone);
        ivCommentLevel1= (ImageView) view.findViewById(R.id.iv_comment_layout_big_rating1);
        ivCommentLevel2= (ImageView) view.findViewById(R.id.iv_comment_layout_big_rating2);
        ivCommentLevel3= (ImageView) view.findViewById(R.id.iv_comment_layout_big_rating3);
        ivCommentLevel4= (ImageView) view.findViewById(R.id.iv_comment_layout_big_rating4);
        ivCommentLevel5= (ImageView) view.findViewById(R.id.iv_comment_layout_big_rating5);
        ivSelectPhrase1= (ImageView) view.findViewById(R.id.iv_comment_layout_phrase1);
        ivSelectPhrase2= (ImageView) view.findViewById(R.id.iv_comment_layout_phrase2);
        ivSelectPhrase3= (ImageView) view.findViewById(R.id.iv_comment_layout_phrase3);
        ivSelectPhrase4= (ImageView) view.findViewById(R.id.iv_comment_layout_phrase4);
        tvPhrase1= (TextView) view.findViewById(R.id.tv_comment_layout_phrase1);
        tvPhrase2= (TextView) view.findViewById(R.id.tv_comment_layout_phrase2);
        tvPhrase3= (TextView) view.findViewById(R.id.tv_comment_layout_phrase3);
        tvPhrase4= (TextView) view.findViewById(R.id.tv_comment_layout_phrase4);
        etSuggession= (EditText) view.findViewById(R.id.et_comment_layout_suggession);
        btnSubmit= (Button) view.findViewById(R.id.btn_comment_layout_submit);
        ivCommentLevel1.setOnClickListener(listener);
        ivCommentLevel2.setOnClickListener(listener);
        ivCommentLevel3.setOnClickListener(listener);
        ivCommentLevel4.setOnClickListener(listener);
        ivCommentLevel5.setOnClickListener(listener);
        ivSelectPhrase1.setOnClickListener(listener);
        ivSelectPhrase2.setOnClickListener(listener);
        ivSelectPhrase3.setOnClickListener(listener);
        ivSelectPhrase4.setOnClickListener(listener);
        btnSubmit.setOnClickListener(listener);
        ivRepairerStars.add(ivRepairerStar1);
        ivRepairerStars.add(ivRepairerStar2);
        ivRepairerStars.add(ivRepairerStar3);
        ivRepairerStars.add(ivRepairerStar4);
        ivRepairerStars.add(ivRepairerStar5);
        ivCommentStars.add(ivCommentLevel1);
        ivCommentStars.add(ivCommentLevel2);
        ivCommentStars.add(ivCommentLevel3);
        ivCommentStars.add(ivCommentLevel4);
        ivCommentStars.add(ivCommentLevel5);
        commentDialog = new Dialog(this, R.style.transparentFrameWindowStyle);
        commentDialog.setContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        Window window = commentDialog.getWindow();
        // 设置显示动画
        window.setWindowAnimations(R.style.main_menu_animstyle);
        WindowManager.LayoutParams wl = window.getAttributes();
        wl.x = 0;
        wl.y = getWindowManager().getDefaultDisplay().getHeight();
        // 以下这两句是为了保证按钮可以水平满屏
        wl.width = ViewGroup.LayoutParams.MATCH_PARENT;
        wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;

        // 设置显示位置
        commentDialog.onWindowAttributesChanged(wl);
        // 设置点击外围解散
        commentDialog.setCanceledOnTouchOutside(true);
        commentDialog.show();
        for(int i=0;i<detailEntity.getOrder().getRepairer().getStar();i++)
        {
            ivRepairerStars.get(i).setImageResource(R.mipmap.order_star_small_selected2x);
        }
        //tvRepairerName.setText(detailEntity.getOrder().getRepairer().getName().toString());
        tvRepairerName.setText("");
        tvRepairerSkill.setText(detailEntity.getOrder().getRepairer().getField());
//        tvRepairerPhone.setText(detailEntity.getOrder().getRepairer().getPhone().toString());
        tvRepairerPhone.setText("");
        HashMap<String,String> map=new HashMap<>();
        baseDataManager.getUserCommentPhrase(map, new ICallBack() {
            @Override
            public void onSuccess(String string) {
                PhrasesCommentEntity entity=JSONObject.parseObject(string,PhrasesCommentEntity.class);
                if(entity.getRc()==0)
                {
                    tvPhrase1.setText(entity.getPhrases().get(0).getText());
                    tvPhrase2.setText(entity.getPhrases().get(1).getText());
                    tvPhrase3.setText(entity.getPhrases().get(2).getText());
                    //tvPhrase4.setText(entity.getPhrases().get(3).getText());
                }
            }

            @Override
            public void onError(VolleyError error) {

            }
        });
    }
    //当销毁activity的时候，取消网络请求，这也正是volley框架的优点之一
    @Override
    protected void onDestroy() {
        super.onDestroy();
        orderManager.requestQueue.cancelAll(RepairOrderManager.class);
    }
}
